#include "restarter.h"
#include <string>
#include "fileUtils.h"
#include <Windows.h>
#include <shellapi.h>
#include "App.h"

bool Restarter::startUpdateTool()
{
	String path = FileUtils::parentDir(FileUtils::exePath());
	String file = path + L"\\ffplayer-update.exe";
	if (!FileUtils::exist(file.c_str())) {
		return false;
	}
	HINSTANCE inst = ShellExecute(nullptr, L"open", file.c_str(), nullptr, path.c_str(), SW_HIDE);
	if ((INT_PTR)inst > 32) {
		return true;
	}
	else {
		return false;
	}
    return false;
}

bool Restarter::exit()
{
	App::inst().requestExit();
    return true;
}
